import request from '@/utils/request'


// 新增公告
export function addAnnouncement(data) {
  return request({
    url: '/announcements',
    method: 'post',
    data
  })
}

// 获取公告列表
export function getAnnouncementList(params) {
  return request({
    url: '/announcements/page',
    method: 'get',
    params
  })
}

// 删除公告
export function deleteAnnouncement(id) {
  return request({
    url: `/announcements/${id}`,
    method: 'delete'
  })
}

// 更新公告
export function updateAnnouncement(data) {
  return request({
    url: `/announcements`,
    method: 'put',
    data
  })
}

// 获取公告详情
export function getAnnouncementDetail(id) {
  return request({
    url: `/announcements/${id}`,
    method: 'get'
  })
}

// 立即发布公告
export function publishAnnouncement(id) {
  return request({
    url: `/announcements/publish/${id}`,
    method: 'post'
  })
}

// 取消发布公告
export function unpublishAnnouncement(id) {
  return request({
    url: `/announcements/unpublish/${id}`,
    method: 'post'
  })
}


